package com.meditor.lib
{
	import flash.display.BitmapData;
	import flash.events.Event;
	import flash.events.IEventDispatcher;
	import flash.system.LoaderContext;
	import flash.utils.ByteArray;
	
	/**
	 * 读取图片的loader
	 * 
	 */	
	public class ImageLoader extends BaseLoader
	{
		public var _data:BitmapData;
		
		/** 
		 * 构造函数
		 */		
		public function ImageLoader(obj:Object = null,lc:LoaderContext=null)
		{
			_type = BaseContstant.TYPE_LOADER_IMAGELOADER;
			if(obj != null)
			{
				if(obj is ByteArray)
				{
					loadBytes(obj as ByteArray,lc);
				}
				else if(obj is String)
				{
					loadResource(obj as String,lc);
				}
				else
				{
					throw new Error("参数错误，构造函数第一参数只接受ByteArray或String");
				}
			}
		}
		
		/**
		 * 加载成功，发布成功事件
		 * 
		 */		
		override protected function completeFunction(event:Event):void
		{
			_data = _loader.content["bitmapData"];
			super.completeFunction(event);
		}
		
		override public function clear():void
		{
			_data = null;
			super.clear();
		}
	}
}